Opened 23 months ago

Closed 22 months ago

Last modified 22 months ago

#5336 closed defect (fixed)

topogeometry cast to topoelement

Reported by: robe Owned by: robe
Priority: medium Milestone: PostGIS 3.4.0
Component: topology Version: master
Keywords: Cc:

Description (last modified by robe)

When you want to pass in a topogeom as a topoelement for building, the syntax is pretty ugly and hard to explain.

As discussed in this thread https://lists.osgeo.org/pipermail/postgis-users/2023-February/045845.html

In order to build hierarchical topoelement using topogeom, you need to do this ugly thing of

TopoElementArray_Agg( ARRAY[(topo).id,(topo).layer_id]::topology.topoelement )

It would be cleaner if we have a topoelementArray_agg that takes a topogeometry or have topogeometry be able to autocast to a topoelement.

Then the above would reduce to

TopoElementArray_Agg( topo )

Change History (8)

comment:1 by robe, 23 months ago

Component: postgistopology
Owner: changed from pramsey to robe

comment:2 by robe, 23 months ago

Description: modified (diff)

comment:3 by robe, 23 months ago

Summary: topoelementarray_agg that takes topogeomtopoelementarray_agg that takes topogeometry

comment:4 by strk, 23 months ago

If you do this consider making sure all topogeometries are from the same topology and layer_id, as can only imagine trouble if you try to create a TopoGeometry composed by elements coming from different topologies (we don't have referential integrity there)

comment:5 by robe, 23 months ago

I'm going to test the performance of this out, but here is what my plan is.

CREATE OR REPLACE FUNCTION topology.topoelement(topo
	topology.topogeometry)
    RETURNS topology.topoelement
    LANGUAGE sql
    COST 1
    IMMUTABLE PARALLEL SAFE
AS  $$SELECT ARRAY[topo.id,topo.layer_id]::topology.topoelement;$$;

-- note you can't create a cast against a domain, but you can create a cast against the underlying type of domain
CREATE CAST (topogeometry AS int[]) WITH FUNCTION topoelement(topogeometry) AS IMPLICIT;

Once you do the above:

This works:


SELECT TopoElementArray_Agg(NULL::topogeometry)

without the cast in place, you get error:

function topoelementarray_agg(topogeometry) does not exist

comment:6 by Sandro Santilli <strk@…>, 22 months ago

Resolution: fixed
Status: newclosed

In cf2b98c/git:

Support topogeometry cast to topoelement

Use backing function TopoElement
Closes #5336 for PostGIS 3.4.0

comment:7 by robe, 22 months ago

Summary: topoelementarray_agg that takes topogeometrytopogeometry cast to topoelement

comment:8 by Sandro Santilli <strk@…>, 22 months ago

In 62a2469/git:

Fix restore of dumps with 3.4.0 topology in postgis_restore.pl

References #5336

Note: See TracTickets for help on using tickets.